package com.inet.activity;


import com.inet.consoleservices.R;
import com.inet.receiver.MyHandler;
import com.inet.util.L;

import android.app.Activity;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

public class WarningActivity extends Activity implements OnClickListener{
	
	private TextView tv1;
	private TextView tv2;
	private TextView tv3;
	private TextView tv4;
	
	private static int t1;
	private static int t2;
	private static int t3;
	private static int t4;
	
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			requestWindowFeature(Window.FEATURE_NO_TITLE);
			this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
					WindowManager.LayoutParams.FLAG_FULLSCREEN);
			this.getWindow().addFlags(
					WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
			getWindow().getDecorView().setSystemUiVisibility(
					View.SYSTEM_UI_FLAG_LAYOUT_STABLE
							| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
							| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
							| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
							| View.SYSTEM_UI_FLAG_FULLSCREEN
							| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
			setContentView(R.layout.activity_warning);
			
			
			initView();
			
		}
		
		private void initView() {
			tv1=(TextView) findViewById(R.id.tv1);
			tv2=(TextView) findViewById(R.id.tv2);
			tv3=(TextView) findViewById(R.id.tv3);
			tv4=(TextView) findViewById(R.id.tv4);
			
			tv1.setOnClickListener(this);
			tv2.setOnClickListener(this);
			tv3.setOnClickListener(this);
			tv4.setOnClickListener(this);
			
		}

		@Override
		public void onBackPressed() {
//			super.onBackPressed();
		}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.tv1:
			t1++;
			break;
		case R.id.tv2:
			t2++;
			break;
		case R.id.tv3:
			t3++;
			break;
		case R.id.tv4:
			t4++;
			L.i("t1="+t1+"-t2="+t2+"-t3="+t3+"-t4="+t4);
			if(t1>4&&t2>4&&t3>4&&t4>4){
				MyHandler handler=new MyHandler(this);
				handler.removeMessages(MyHandler.CLOSELAUNCHER);
				Settings.System.putInt(getContentResolver(),
						"is_user_lock", 0);
				handler.sendEmptyMessageDelayed(MyHandler.OPENLAUNCHER, 100);
				
			}
			break;

		default:
			break;
		}
	}
		
	@Override
	protected void onResume() {
		super.onResume();
		L.i("--t1="+t1+"-t2="+t2+"-t3="+t3+"-t4="+t4);
	}
		
}
